<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page isELIgnored="false" %>
<%@ taglib uri="/permission" prefix="pe" %>

<jsp:include page="../../include/top.jsp"/>
<div class="main_body">
    <div class="span9 page_message">
        <section id="contents">
            <ul class="tab-nav nav">
                <li class="current">
                    <a href="">预约列表<span class="arrow fa fa-sort-up"></span></a>
                </li>
                <li><a href="javascript:send()">发送<span class="arrow fa fa-sort-up"></span></a></li>
                <li><a href="javascript:cancel()">撤消<span class="arrow fa fa-sort-up"></span></a></li>
            </ul>
            <div class="table-bar">
                <div class="fl">
                    <%--<div class="tools">--%>
                    <%--<a class="btn btn-success" href="${BasePath}/order/product/toAdd?${PublicParams}">新增</a>--%>
                    <%--<a class="btn btn-success" href="${BasePath}/order/product/toAdd?${PublicParams}">新增</a>--%>
                    <%--<a class="btn btn-success" href="${BasePath}/order/product/toAdd?${PublicParams}">新增</a>--%>
                    <%--</div>--%>
                    <div class="search-form fr cf">
                        <form id="myForm" name="myForm" action="${BasePath}/order/reservation/list?${PublicParams}" method="post">
                            订单号：<input type="text" class="txt100" name="orderNo" value="${orderNo }"/>
                            购买人：<input type="text" class="txt100" name="buyUser" value="${buyUser}"/>
                            使用人：<input type="text" class="txt100" name="endUser" value="${endUser }"/>
                            手机号：<input type="text" class="txt100" name="mobile" value="${mobile }"/>
                            卡号：<input type="text" class="txt100" name="cardNumber" value="${cardNumber }"/>
                            预约时间从:<input type="text" class="txt100" id="reservationStartDate" name="reservationStartDate" value="${reservationStartDate}" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',maxDate:'#F{$dp.$D(\'reservationEndDate\')}',readOnly:'false'})"/>
                            至
                            <input type="text" class="txt100" id="reservationEndDate" name="reservationEndDate" value="${reservationEndDate}" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',minDate:'#F{$dp.$D(\'reservationStartDate\')}',readOnly:'false'})"/>

                            <%--有效期：<input type="text" id="startDate" name="startDate" value="${startDate}" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',maxDate:'#F{$dp.$D(\'endDate\')}',readOnly:'false'})"/>--%>
                            <%--至--%>
                            <%--<input type="text" id="endDate" name="endDate" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',minDate:'#F{$dp.$D(\'startDate\')}',readOnly:'false'})"/>--%>
                            团单：<select name="groupOrderId">
                            <option value="-1">请选择...</option>
                            <c:forEach items="${groupOrderList}" var="groupOrder">
                                <option value="${groupOrder.id}"
                                        <c:if test="${groupOrderId==groupOrder.id}">selected</c:if>   >${groupOrder.groupName}</option>
                            </c:forEach>
                        </select>
                            <input type="submit" value="查询" class="btn btn-success " style="margin-top: -10px"/>
                            <input type="hidden" name="start" id="start" value="${start }"/>
                            <input type="hidden" name="limit" id="limit" value="${limit }"/>
                        </form>
                    </div>
                </div>
            </div>
            <div class="data-table">
                <div class="table-striped">
                    <table cellspacing="1">
                        <thead>
                        <tr>
                            <th class="row-selected row-selected">
                                <input type="checkbox" id="checkAll" class="check-all regular-checkbox"><label for="checkAll"></label>
                            </th>
                            <th>状态</th>
                            <th>预约日期</th>
                            <th>通知</th>
                            <th>订单号</th>
                            <th>团体名称</th>
                            <th>购买人</th>
                            <th>体检人</th>
                            <th>性别</th>
                            <th>手机</th>
                            <th>电话</th>
                            <th>商家名称</th>
                            <th>分院名称</th>
                            <th>套餐名称</th>
                            <%--<th>加项内容</th>--%>
                            <th>预约备注</th>
                            <th>身份证</th>
                            <%--<th>操作员</th>--%>
                            <%--<th>修改时间</th>--%>
                            <%--<th>操作</th>--%>
                        </tr>
                        </thead>
                        <tbody>
                        <c:forEach items="${list}" var="bean">
                            <tr>
                                <td><input type="checkbox" id="check_${bean.id}" name="ids[]" value="${bean.id}" class="ids regular-checkbox"><label for="check_${bean.id}"></label></td>
                                    <%--<td class="id">${bean.id}</td>--%>
                                <td class="id">
                                    <c:if test="${bean.status=='0'}">
                                        <b><font color="red">未发送</font></b>
                                    </c:if>
                                    <c:if test="${bean.status=='1'}">
                                        <b><font color="green">已发送</font></b>
                                    </c:if>
                                    <c:if test="${bean.status=='2'}">
                                        <b><font color="orange">再次发送</font></b>
                                    </c:if>
                                    <c:if test="${bean.status=='3'}">
                                        <b><font color="blank">已撤销</font></b>
                                    </c:if>
                                    <c:if test="${bean.confirmed=='0'}">
                                        <b><font color="red">未确认</font></b>
                                    </c:if>
                                    <c:if test="${bean.confirmed=='1'}">
                                        <b><font color="green">已确认</font></b>
                                    </c:if>
                                </td>
                                <td>
                                    <script>
                                        formatDate(${bean.reserveDate});
                                    </script>
                                </td>
                                <td>${bean.institutionName}</td>
                                <td>${bean.orderNo}</td>
                                <td>${bean.groupName}</td>
                                <td>${bean.buyUser}</td>
                                <td>${bean.endUser}</td>
                                <td>${bean.sex}</td>
                                <td>${bean.mobile}</td>
                                <td>${bean.phone}</td>
                                <td>${bean.institutionName}</td>
                                <td>${bean.branch}</td>
                                <td>${bean.productName}</td>
                                <td>${bean.comments}</td>
                                <td>${bean.idCard}</td>

                                    <%--<td>--%>
                                    <%--<c:choose>--%>
                                    <%--<c:when test="${bean.onsale==1}">--%>
                                    <%--<span style="color: green">是</span>--%>
                                    <%--</c:when>--%>
                                    <%--<c:otherwise>--%>
                                    <%--<span style="color: red">否</span>--%>
                                    <%--</c:otherwise>--%>
                                    <%--</c:choose>--%>
                                    <%--</td>--%>
                                    <%--<td>${bean.onsale}</td>--%>
                                    <%--<td>--%>
                                    <%--<pe:permission key="update">--%>
                                    <%--<a href="${BasePath}/order/product/toEdit?id=${bean.id}&${PublicParams}">修改</a>--%>
                                    <%--</pe:permission>--%>
                                    <%--<pe:permission key="delete">--%>
                                    <%--<a class="confirm ajax-get" href="${BasePath}/order/product/multiDel?ids=${bean.id}&${PublicParams}">删除</a>--%>
                                    <%--</pe:permission>--%>
                                    <%--</td>--%>
                            </tr>
                        </c:forEach>
                        </tbody>
                    </table>
                    <div class="page" id="pager"></div>
                    <script type="text/javascript">
                        var sign = 0;
                        window.onload = function () {
                            PAGER.initPager('${start}', '${total}', '${limit}', 8, 'pager', getData);
                        }
                        function getData(currentPage, pageSize) {
                            if (sign > 0) {
                                $("#start").val(currentPage);
                                $("#limit").val(pageSize);
                                $("#myForm").submit();
                            }
                            sign = 1;
                        }
                    </script>
                </div>
            </div>
        </section>
    </div>
</div>
<jsp:include page="../../include/bottom.jsp"/>
<script>
    function send() {
        var idArray = new Array();
        $("input[name='ids[]']:checked").each(function () {
            var txt = $(this).val();
            idArray.push(txt);
        });
        if (idArray.length == 0) {
            layer.msg('请选择一条记录进行操作！', {icon: 5});
            return false;
        } else {
            layer.msg('确认要发送该订单吗？', {
                time: 0 //不自动关闭
                , btn: ['确定', '取消']
                , yes: function (index) {
                    layer.close(index);
                    $.getJSON("${BasePath}/order/reservation/send?ids="+idArray.toString(), function (data) {
                        if(data.errno==0){
                            layer.msg("操作成功！");
                            window.location.reload();
                        }else{
                            layer.msg(data.errdesc, {icon: 5});
                        }
                    });
                }
            });
        }
    }
    function cancel() {
        var idArray = new Array();
        $("input[name='ids[]']:checked").each(function () {
            var txt = $(this).val();
            idArray.push(txt);
        });
        if (idArray.length == 0) {
            layer.msg('请选择一条记录进行操作！', {icon: 5});
            return false;
        } else {
            layer.msg('确认要取消该订单吗？', {
                time: 0 //不自动关闭
                , btn: ['确定', '取消']
                , yes: function (index) {
                    layer.close(index);
                    $.getJSON("${BasePath}/order/reservation/cancel?ids="+idArray.toString(), function (data) {
                        if(data.errno==0){
                            layer.msg("操作成功！");
                            window.location.reload();
                        }else{
                            layer.msg(data.errdesc, {icon: 5});
                        }
                    });
                }
            });
        }
    }
</script>